package com.ruoyi.common.config;


import com.ruoyi.common.utils.file.AliyunOssUploadUtils;
import com.ruoyi.common.utils.properties.AliOssProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
public class OssConfig {
    @Bean
    @ConditionalOnMissingBean//保证spring容器类中只创建一个文件传输工具类，当没有此类时才创建
    public AliyunOssUploadUtils aliOssUtil(AliOssProperties aliOssProperties) {
        log.info("开始创建阿里云文件传输工具类对象，{}",aliOssProperties);
        return new AliyunOssUploadUtils(aliOssProperties.getEndpoint(),
                aliOssProperties.getAccessKeyId(),
                aliOssProperties.getAccessKeySecret(),
                aliOssProperties.getBucketName());
    }
}
